const app = getApp()
let currentIndex = 0
Page({
//   f05e0b
// ff6600
// ff8939
// e7cf39
// fcea7c
  data: {
    sign:false,
    prizes: [
      { title: '0.2元红包', background: '#f8d384', fonts: [{ text: '0.2元红包', top: '18%' }] },
      { title: '10元红包', background: '#f9e3bb', fonts: [{ text: '10元红包', top: '18%' }] },
      { title: '0.1元红包', background: '#f8d384', fonts: [{ text: '0.1元红包', top: '18%' }] },
      { title: '1元红包', background: '#f9e3bb', fonts: [{ text: '1元红包', top: '18%' }] },
      { title: '100元红包', background: '#f8d384', fonts: [{ text: '100元红包', top: '18%' }] },
      { title: '0.5元红包', background: '#f9e3bb', fonts: [{ text: '0.5元红包', top: '18%' }] },

    ],
   
    defaultStyle: {
      fontColor: '#f05e0b',
      fontSize: '12px',
    },
    blocks: [
      {padding: '8px', background: '#f0d224' },
      {padding: '4px', background: '#fff',  },
      

    ],
    buttons: [
      { radius: '32px', background: '#fff' },
      { radius: '30px',  background: '#e7cf39',pointer: true, },
      {
        radius: '26px', background: '#fcea7c',
        // fonts: [{ text: '开始\n抽奖', fontSize: '18px', top: -18 }],
        imgs: [{ src: '/images/button.png', width: '68%', top: '-50%' }]
      }
    ],
  },
  start () {
    // 获取抽奖组件实例
    const child = this.selectComponent('#myLucky')
    // 调用play方法开始旋转
    child.$lucky.play()
    // 用定时器模拟请求接口
    setTimeout(() => {
      // 3s 后得到中奖索引
      let index = 0 
      if(currentIndex === 0){
        currentIndex = 2
        index = 2
      }else{
        currentIndex = 0
        index = 0
      }
      // 调用stop方法然后缓慢停止
      child.$lucky.stop(index)
    }, 3000)
  },
  end (event) {
    // 中奖奖品详情
    console.log(event.detail)
  },
 
})